﻿Namespace Geometry
    Public Class Point3d

        ''' <summary>
        ''' x坐标
        ''' </summary>
        ''' <remarks></remarks>
        Private _p_x As Double
        ''' <summary>
        ''' y坐标
        ''' </summary>
        ''' <remarks></remarks>
        Private _p_y As Double
        ''' <summary>
        ''' z坐标
        ''' </summary>
        ''' <remarks></remarks>
        Private _p_z As Double
        ''' <summary>
        ''' 标识
        ''' </summary>
        ''' <remarks></remarks>
        Private _p_flag As Integer

        Public Property p_x() As Double
            Get
                Return _p_x
            End Get
            Set(value As Double)
                _p_x = value
            End Set
        End Property

        Public Property p_y() As Double
            Get
                Return _p_y
            End Get
            Set(value As Double)
                _p_y = value
            End Set
        End Property

        Public Property p_z() As Double
            Get
                Return _p_z
            End Get
            Set(value As Double)
                _p_z = value
            End Set
        End Property

        Public Property p_flag() As Integer
            Get
                Return _p_flag
            End Get
            Set(value As Integer)
                _p_flag = value
            End Set
        End Property

        Public Sub New()
            p_x = 0
            p_y = 0
            p_z = 0
            p_flag = 0
        End Sub
        ''' <summary>
        ''' 求点与点之间的三维距离
        ''' </summary>
        ''' <param name="pt"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetDis3D(ByVal pt As Point3d) As Double
            Return Math.Sqrt(Math.Pow((p_x - pt.p_x), 2) + Math.Pow((p_y - pt.p_y), 2) + Math.Pow((p_z - pt.p_z), 2))
        End Function
        ''' <summary>
        ''' 求点与点之间的二维距离
        ''' </summary>
        ''' <param name="pt"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetDis2D(ByVal pt As Point3d) As Double
            Return Math.Sqrt(Math.Pow((p_x - pt.p_x), 2) + Math.Pow((p_y - pt.p_y), 2))
        End Function

        Public Function pow2for2d() As Double
            Return Me.p_x * Me.p_x + Me.p_y * Me.p_y
        End Function

        Public Function isonLorR(ByVal startp As Point3d, ByVal endp As Point3d) As Boolean
            If (endp.p_x - startp.p_x) * (p_y - startp.p_y) - (endp.p_y - startp.p_y) * (p_x - startp.p_x) > 0 Then
                Return False
            Else
                Return True
            End If
        End Function
    End Class
End Namespace

